package com.bh.shipment.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bh.common.utils.DateUtils;
import com.bh.common.utils.SecurityUtils;
import com.bh.shipment.domain.JcBerthStand;
import com.bh.shipment.mapper.JcBerthStandMapper;
import com.bh.shipment.service.IJcBerthStandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 经由站Service业务层处理
 *
 * @author slx
 * @date 2023-04-22
 */
@Service
public class JcBerthStandServiceImpl extends ServiceImpl<JcBerthStandMapper, JcBerthStand> implements IJcBerthStandService {
    @Autowired
    private JcBerthStandMapper jcBerthStandMapper;

    /**
     * 查询经由站
     *
     * @param id 经由站主键
     * @return 经由站
     */
    @Override
    public JcBerthStand selectJcBerthStandById(Long id) {
        return jcBerthStandMapper.selectById(id);
    }

    /**
     * 查询经由站列表
     *
     * @param jcBerthStand 经由站
     * @return 经由站
     */
    @Override
    public List<JcBerthStand> selectJcBerthStandList(JcBerthStand jcBerthStand) {
        return jcBerthStandMapper.selectJcBerthStandList(jcBerthStand);
    }

    @Override
    public List<JcBerthStand> selectJcBerthStandListByShipmentId(Long shipmentId) {
        return jcBerthStandMapper.selectJcBerthStandListByShipmentId(shipmentId);
    }

    /**
     * 新增经由站
     *
     * @param jcBerthStand 经由站
     * @return 结果
     */
    @Override
    public int insertJcBerthStand(JcBerthStand jcBerthStand) {
        jcBerthStand.setCreateTime(DateUtils.getNowDate());
        jcBerthStand.setCreateName(SecurityUtils.getUsername());
        return jcBerthStandMapper.insert(jcBerthStand);
    }

    /**
     * 修改经由站
     *
     * @param jcBerthStand 经由站
     * @return 结果
     */
    @Override
    public int updateJcBerthStand(JcBerthStand jcBerthStand) {
        return jcBerthStandMapper.updateById(jcBerthStand);
    }

    /**
     * 批量删除经由站
     *
     * @param ids 需要删除的经由站主键
     * @return 结果
     */
    @Override
    public int deleteJcBerthStandByIds(Long[] ids) {
        return jcBerthStandMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除经由站信息
     *
     * @param id 经由站主键
     * @return 结果
     */
    @Override
    public int deleteJcBerthStandById(Long id) {
        return jcBerthStandMapper.deleteById(id);
    }

    @Override
    public int deleteJcBerthStandByShipmentId(Long shipmentId) {
        return jcBerthStandMapper.deleteJcBerthStandByShipmentId(shipmentId);
    }
}